﻿<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>

<fmt:setBundle basename="ApplicationMessage" />
<fmt:setLocale value="zh_CN" />

<div class="modal-dialog x-modal-dialog" style="width:800px;">

  <div class="modal-content">

    <div class="modal-header x-breadcrumb clearfix">

      <h2><i class="glyphicon glyphicon-fire" title="添加商品"></i>&nbsp;&nbsp;<span>添加商品</span></h2>

      <button type="button" class="close" data-dismiss="modal">&times;</button>

    </div>

    <form class="form-horizontal" method="POST" action="${ctx.host}/credit-products" data-validate="true">
      
      <div class="modal-body">
        <div class="form-group x-form-group">
          <label class="col-xs-2 control-label">商品名称</label>
          <div class="pull-left" style="width: 30%">
            <input type="text" class="form-control"  data-validate="required"  name="name" placeholder="请输入商品名称" />
          </div>
          <label class="col-xs-2 control-label">商品标签</label>
          <div class="pull-left" style="width: 30%">
            <select name="inputTags" class="form-control" multiple data-validate="required">
              <option value=""></option>
              <c:forEach var="tag" items="${enums['creditProductTag']}" >
                <option value="${tag}">${tag.description}</option>
              </c:forEach>
            </select>
          </div>
        </div>
        
         <div class="form-group x-form-group">
          <label class="col-xs-2 control-label">产品原价</label>
          <div class="pull-left" style="width: 30%">
            <input type="text" class="form-control" data-validate="required|number" name="price" placeholder="请输入积分值" />
          </div>
          <label class="col-xs-2 control-label">产品现价</label>
          <div class="pull-left" style="width: 30%">
            <input type="text" class="form-control" data-validate="required|number" name="currentPrice" placeholder="请输入积分值" />
          </div>
        </div>
        
        <div class="form-group x-form-group">
          <label class="col-xs-2 control-label">产品数量</label>
          <div class="pull-left" style="width: 30%">
            <input type="text" class="form-control" data-validate="required|number" name="amount" placeholder="请输入产品数量" />
          </div>
        </div>
        
        <div class="form-group x-form-group">
          <label class="col-xs-2 control-label">简介</label>
          <div class="pull-left" style="width: 77%">
            <textarea name="summary" class="form-control" data-validate="required" rows="5" style="width: 100%;"></textarea>
          </div>
        </div>
        
        <div class="form-group x-form-group">
          <label class="col-xs-2 control-label">封面</label>
          <div class="col-xs-8 pull-left upload-cover" style="width: 450px; height: 270px;">
            <button type="button" id="pickCover" class="edit-btn"><span class="glyphicon glyphicon-folder-open" aria-hidden="true"></span>&nbsp;&nbsp;选择文件</button>
            <div id="coverPreviewList">
              <img id="coverPreview" src=""/>
            </div>
            <label id="messageCover" class="control-label messageCover hide"></label>
          </div>
          <input type="hidden" id="cover" name="cover" value="" />
        </div>
        
        
      </div>

      <div class="modal-footer clearfix">
        <button type="submit" class="btn btn-success btn-shadow btn-shadow-success x-btn">确定</button>&nbsp;&nbsp;&nbsp;&nbsp;
        <button type="button" class="btn btn-default btn-shadow btn-shadow-default x-btn" data-dismiss="modal">取消</button>
      </div>
    </form>

  </div>

</div>

<script>
  $(function() {
    $('.date').datetimepicker({
      format: 'yyyy-mm-dd',
      autoclose: true,
      language: 'zh-CN',
      todayBtn: 'linked',
      todayHighlight: true,
      pickerPosition: 'bottom-right',
      minView: 'month'
    });
    
    $('select[name="inputTags"]').select2({
        placeholder : '请选择产品标签',
        minimumResultsForSearch : 5,
        allowClear : true,
      });
    
  })
</script>
